package com.leo.ibatis.demo.service.impl;

import java.util.List;

import com.leo.ibatis.demo.base.Service;
import com.leo.ibatis.demo.criteria.BannerdataCriteria;
import com.leo.ibatis.demo.dao.BannerdataDao;
import com.leo.ibatis.demo.domain.Bannerdata;
import com.leo.ibatis.demo.service.BannerdataService;

public class BannerdataServiceImpl extends Service implements BannerdataService {

	private BannerdataDao bannerdataDao;

	public void setBannerdataDao(BannerdataDao bannerdataDao) {
		this.bannerdataDao = bannerdataDao;
	}

	public void insert(Bannerdata bannerdata) {
		bannerdataDao.insert(bannerdata);
	}

	public int update(Bannerdata bannerdata) {
		int actualRowsAffected = 0;
		
		String favcategory = bannerdata.getFavcategory();

		Bannerdata _oldBannerdata = bannerdataDao.select(favcategory);
		
		if (_oldBannerdata != null) {
			actualRowsAffected = bannerdataDao.update(bannerdata);
		}
		
		return actualRowsAffected;
	}

	public int delete(String favcategory) {
		int actualRowsAffected = 0;
		
		Bannerdata _oldBannerdata = bannerdataDao.select(favcategory);
		
		if (_oldBannerdata != null) {
			actualRowsAffected = bannerdataDao.delete(favcategory);
		}
		
		return actualRowsAffected;
	}
	
	public Bannerdata select(String favcategory) {
		return bannerdataDao.select(favcategory);
	}

	public List<Bannerdata> list(BannerdataCriteria bannerdataCriteria) {
		return bannerdataDao.list(bannerdataCriteria);
	}
	
	public List<Bannerdata> listOnPage(BannerdataCriteria bannerdataCriteria) {
		return bannerdataDao.listOnPage(bannerdataCriteria);
	}

}
